<?php

use App\Http\Controllers\AuthController;
use App\Http\Controllers\PostController;
use App\Models\Post;
use Illuminate\Container\Attributes\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/user', function (Request $request) {
    return $request->user();
})->middleware('auth:sanctum');
Route::get('/', fn() => 'WelcomeController@index');
// Route::apiResource('posts', PostController::class)->except(['index', 'show'])
//     ->middleware('auth:sanctum');
Route::middleware('auth:sanctum')->group(function () {
    Route::controller(PostController::class)->group(function () {

        Route::post('/posts', 'store');

        Route::put('/posts/{post}', 'update');
        Route::delete('/posts/{post}', 'destroy');
    });
});
Route::get('/posts', [PostController::class, 'index']);
Route::get('/posts/{post}', [PostController::class, 'show']);
Route::controller(AuthController::class)->group(function () {
    Route::post('/register', 'register');
    Route::post('/login', 'login');
    Route::post('/logout', 'logout')->middleware('auth:sanctum');
});
